//
//  HBIncomeDetailTotalCell.m
//  HuoBao
//
//  Created by chaiyanan on 15/12/2.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "HBIncomeDetailTotalCell.h"

@interface HBIncomeDetailTotalCell ()

@property (nonatomic, strong) NSArray *subAry;

@end

@implementation HBIncomeDetailTotalCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.backgroundColor = [LCCommon getColor:@"28292d"];
        self.subAry = @[@"本金收益",@"体验金收益",@"加息收益"];
        [self createCustomView];
    }
    return self;
}

- (void)createCustomView
{
    self.totalIncomePlace = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2 - 60, 43, 120, 3)];
    [self.totalIncomePlace setBackgroundColor:[LCCommon getColor:@"FA9838"]];
    [self addSubview:self.totalIncomePlace];
    self.totalIncomePlace.hidden = YES;
    
    self.totalIncome = [self createLableWithTextColor:[LCCommon getColor:@"fa9838"] font:[UIFont boldSystemFontOfSize:40.0f] text:@"1427.88" textAlignment:NSTextAlignmentCenter frame:CGRectMake(0, 23, SCREEN_WIDTH, 40) superView:self];
    
    UILabel *totalIncomeTitle = [self createLableWithTextColor:[LCCommon getColor:@"666666"] font:[UIFont boldSystemFontOfSize:15.0f] text:@"累计收益(元)" textAlignment:NSTextAlignmentCenter frame:CGRectMake(0, self.totalIncome.y+self.totalIncome.height, SCREEN_WIDTH, 15) superView:self];
    
    for (int i=0;i<self.subAry.count;i++)
    {
        UILabel *lable = [self createContentWithTitle:self.subAry[i] frame:CGRectMake(i*(SCREEN_WIDTH/self.subAry.count), totalIncomeTitle.y+totalIncomeTitle.height+20, SCREEN_WIDTH/(self.subAry.count), 50) superView:self];
        if (i==0)
        {
            self.bjIncome = lable;
        }
        else if (i==1)
        {
            self.tyIncome = lable;
        }
        else
        {
            self.jxIncome = lable;
        }
    }
    
//    UIView *headerBGView = [[UIView alloc]initWithFrame:CGRectMake(0, -500, SCREEN_WIDTH, 650)];
//    headerBGView.backgroundColor = [LCCommon getColor:Main_BackGround_Color];
//    [self.contentView addSubview:headerBGView];
//    [self sendSubviewToBack:headerBGView];
    
}

- (UILabel *)createLableWithTextColor:(UIColor *)color font:(UIFont *)font text:(NSString *)text textAlignment:(NSTextAlignment)textAlignment frame:(CGRect)frame superView:(UIView *)superView
{
    UILabel *lable = [[UILabel alloc]initWithFrame:frame];
    lable.textColor = color;
    lable.font = font;
    lable.text = text;
    lable.textAlignment = textAlignment;
    [superView addSubview:lable];
    return lable;
}

- (UILabel *)createContentWithTitle:(NSString *)title frame:(CGRect)frame superView:(UIView *)superView
{
    UIView *bgView = [[UIView alloc]initWithFrame:frame];
    bgView.backgroundColor = [UIColor clearColor];
    [superView addSubview:bgView];
    
    UILabel *lable = [self createLableWithTextColor:[LCCommon getColor:@"999999"] font:[UIFont systemFontOfSize:16.0f] text:@"140.80" textAlignment:NSTextAlignmentCenter frame:CGRectMake(0,0, bgView.width, 16) superView:bgView];
    [self createLableWithTextColor:[LCCommon getColor:@"666666"] font:[UIFont systemFontOfSize:12.0f] text:title textAlignment:NSTextAlignmentCenter frame:CGRectMake(0, lable.height+10, lable.width, 12) superView:bgView];
    
    return lable;
}


@end
